
import React from 'react'
import ReactDOM from "react-dom";
import {Aletts} from 'components/alert/message'
import {localhost} from 'config/config'

export const encrypt = (Password) => 
		new Hashes.SHA1().hex(
	 		  Password + 'yGRHAdTbsVxKO4hQSIkfceMF76liLmJ5'
		);
		
export const signs=()=>
   new Hashes.SHA1().hex('yGRHAdTbsVxKO4hQSIkfceMF76liLmJ5')

export const Alert =(data,type)=>{

	const Meassage=document.createElement('div');
	Meassage.className='Messages';

	ReactDOM.render(<Aletts data={data} /> ,
		document.querySelector('.messageAlert').appendChild(Meassage));
	
	if(data.code == 200)
		Skips(data,type);
	
}

export const dialog =(data)=>{
	
	ReactDOM.render(<Aletts data={ data } />,
	document.querySelector('.messageAlert'))
	
}

export const Error=(message)=>{
	return{
		code:400,
		message:message,
	}
}

const Skips=(data,type)=>{
	
	if(type == 'EXIT'){
		
		sessionStorage.removeItem('admin_token');
		setTimeout(()=>location.href = "./",2000);
		
	}else if(type == 'LOGIN'){
		
		location.href = localhost + "#/show-data";
		sessionStorage.admin_token=data.data
		
	}
}

